API: gdk: Add gdk_window_new_child() and gdk_window_new_input()
authorBenjamin Otte <otte@redhat.com>
Mon, 17 Oct 2016 18:11:23 +0000 (20:11 +0200)
committerBenjamin Otte <otte@redhat.com>
Mon, 17 Oct 2016 22:22:35 +0000 (00:22 +0200)
This is an attempt to get rid of gdk_window_new() for more specific use
cases. These 2 are for client-side windows - regular ones and input-only
ones resepectively.

So far all those functions just call into gdk_window_new().

docs/reference/gdk/gdk4-sections.txt
gdk/gdkwindow.c
gdk/gdkwindow.h

index 5d581b7efc6e66237b539b699ec17e65ae55ae09..a153e08715744055247b3219244a7e58cc6c9b9d 100644 (file)
@@ -334,6 +334,8 @@ GdkWindowTypeHint
 GdkWindowAttr
 GdkWindowAttributesType
 gdk_window_new
+gdk_window_new_child
+gdk_window_new_input
 gdk_window_destroy
 gdk_window_get_window_type
 gdk_window_get_display
index 541e6a2f0217cb3315072140515aec5a76a45bab..8206b7b967f2496961f96594a2fd7d7e24d38dc1 100644 (file)
@@ -1484,6 +1484,66 @@ gdk_window_new (GdkWindow     *parent,
   return window;
 }
 
+/**
+ * gdk_window_new_child: (constructor)
+ * @parent: the parent window
+ * @event_mask: event mask (see gdk_window_set_events())
+ * @position: placement of the window inside @parent
+ *
+ * Creates a new client-side child window.
+ *
+ * Returns: (transfer full): the new #GdkWindow
+ **/
+GdkWindow *
+gdk_window_new_child (GdkWindow          *parent,
+                      gint                event_mask,
+                      const GdkRectangle *position)
+{
+  GdkWindowAttr attr;
+
+  g_return_val_if_fail (GDK_IS_WINDOW (parent), NULL);
+
+  attr.event_mask = event_mask;
+  attr.wclass = GDK_INPUT_OUTPUT;
+  attr.x = position->x;
+  attr.y = position->y;
+  attr.width = position->width;
+  attr.height = position->height;
+  attr.window_type = GDK_WINDOW_CHILD;
+
+  return gdk_window_new (parent, &attr, GDK_WA_X | GDK_WA_Y);
+}
+
+/**
+ * gdk_window_new_input: (constructor)
+ * @parent: the parent window
+ * @event_mask: event mask (see gdk_window_set_events())
+ * @position: placement of the window inside @parent
+ *
+ * Creates a new client-side input-only window.
+ *
+ * Returns: (transfer full): the new #GdkWindow
+ **/
+GdkWindow *
+gdk_window_new_input (GdkWindow          *parent,
+                      gint                event_mask,
+                      const GdkRectangle *position)
+{
+  GdkWindowAttr attr;
+
+  g_return_val_if_fail (GDK_IS_WINDOW (parent), NULL);
+
+  attr.event_mask = event_mask;
+  attr.wclass = GDK_INPUT_ONLY;
+  attr.x = position->x;
+  attr.y = position->y;
+  attr.width = position->width;
+  attr.height = position->height;
+  attr.window_type = GDK_WINDOW_CHILD;
+
+  return gdk_window_new (parent, &attr, GDK_WA_X | GDK_WA_Y);
+}
+
 static gboolean
 is_parent_of (GdkWindow *parent,
              GdkWindow *child)
index aaaafcbb37b08011e70d976d99ed18f0dbd9d8ed..7bc84bddc0f6ec0539011bf7a7adc1e22eb4ad89 100644 (file)
@@ -498,6 +498,16 @@ GDK_AVAILABLE_IN_ALL
 GdkWindow*    gdk_window_new                   (GdkWindow     *parent,
                                                 GdkWindowAttr *attributes,
                                                 gint           attributes_mask);
+GDK_AVAILABLE_IN_3_90
+GdkWindow *   gdk_window_new_child             (GdkWindow     *parent,
+                                                gint           event_mask,
+                                                const GdkRectangle *position);
+GDK_AVAILABLE_IN_3_90
+GdkWindow *   gdk_window_new_input             (GdkWindow     *parent,
+                                                gint           event_mask,
+                                                const GdkRectangle *position);
+
+
 GDK_AVAILABLE_IN_ALL
 void          gdk_window_destroy               (GdkWindow     *window);
 GDK_AVAILABLE_IN_ALL